#include "UdpServer.hpp"
#include <memory>

std::string default_handler(const std::string& msg){
    std::string s = "Server Get -> ";
    s += msg;
    return s;
}


//服务器启动的时候，需要这样用
// ./UDP_SERVER.exe  port ip   //其实这么做是错的

// ./UDP_SERVER.exe  port
int main(int argc, char* argv[]){
    /* if(argc != 3){
        std::cerr << "please usage : " << "./UDP_SERVER ip port" << std::endl;
        return 1;
    } 
        
    int port = std::stoi(std::string(argv[1]));
    std::string ip = argv[2];
    
    std::unique_ptr<UdpServer> Pserver = std::make_unique<UdpServer>(port, ip);
    */

    if(argc != 2){
        std::cerr << "please usage : " << "./UDP_SERVER  port" << std::endl;
        return 1;
    }

    int port = std::stoi(std::string(argv[1]));
    
    

    std::unique_ptr<UdpServer> Pserver = std::make_unique<UdpServer>(port, default_handler);

    Pserver->Init();
    Pserver->Start();

    return 0;
}